﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using AFCEPF.BankApplication.BLL;
using NUnit.Framework;


namespace AFCEPF.BankApplication.Tests
{
    /// <summary>    
    /// L'attribut [TestFixture] indique à NUnit
    /// que cette classe contient des tests..
    /// </summary>
    [TestFixture]
    class Test_Person
    {
        /// <summary>
        /// L'attribut [Test] indique à NUnit
        /// que cette méthode est un test..
        /// </summary>
        [Test]
        public void Test_Property_Name()
        {
            Person p = new Person();
            p.Name = "aa";

            // Le succès/échec du test dépendra 
            // du résultat de l'appel à la méthode
            // Assert..
            Assert.IsTrue(p.Name == "aa".ToUpper());
        }


        [Test]
        public void Test_Property_FirstName_ForEmptyString()
        {
            Person p = new Person();
            p.FirstName = "";

            // Le succès/échec du test dépendra 
            // du résultat de l'appel à la méthode
            // Assert..
            Assert.IsTrue(p.FirstName == "");
        }

        [Test]
        public void Test_Property_FirstName_ForOver10Chars()
        {
            Person p = new Person();
            p.FirstName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";

            Assert.IsTrue(p.FirstName == "aaaaaaaaaa");
        }

        [Test]
        public void Test_Property_FirstName_ForCorrectLength()
        {
            Person p = new Person();
            p.FirstName = "aaa";

            Assert.IsTrue(p.FirstName == "aaa");
        }


        [Test]
        public void Test_Property_YOB_ForUnderMin()
        {
            Person p = new Person();
            p.YearOfBirth = DateTime.Now.Year - 101;

            Assert.IsTrue(p.YearOfBirth == -1);
        }


        [Test]
        public void Test_Property_YOB_ForOverMax()
        {
            Person p = new Person();
            p.YearOfBirth = DateTime.Now.Year + 1;

            Assert.IsTrue(p.YearOfBirth == -1);
        }


        [Test]
        public void Test_Property_YOB_ForCorrectValue()
        {
            Person p = new Person();
            p.YearOfBirth = DateTime.Now.Year - 1;

            Assert.IsTrue(p.YearOfBirth == DateTime.Now.Year - 1);
        }

        [Test]
        public void Test_Property_Age_ForCorrectValue()
        {
            Person p = new Person();
            p.YearOfBirth = DateTime.Now.Year - 1;

            int age = DateTime.Now.Year - p.YearOfBirth;

            Assert.IsTrue(p.Age == age);
        }

        [Test]
        public void Test_Property_Age_ForInCorrectYearOfBirth()
        {
            Person p = new Person();
            p.YearOfBirth = DateTime.Now.Year - 101;

            Assert.IsTrue(p.Age == -1);
        }


        [Test]
        public void Test_Ctor_TwoParams()
        {
            Person p = new Person("toto", "titi");
            Assert.IsTrue(p.Name == "TOTO" && p.FirstName == "titi");
        }

    }
}
